<?php
require('core.php');
require('funcs/debug.class.php');
//The main brains of Xwire

$act = $_GET['act'];


switch($act) {

	case 'commence':
		//Registers the client on the system with a new session
	
		$version = $_GET['ver'];
		$clientEmail = $_GET['email'];
		$authcode = $_GET['authcode'];
		xw::analyseAndInit($version, $clientEmail, $authcode);
	break;
	
	case 'register':
	
		$username = $_GET['username'];
		$email = $_GET['email'];
		$password = $_GET['password'];
		
		xw::registerUser($username, $email, $password);
	break;
	
	case 'log':
		//Logs a new message into the current chat session
		$left = xw::decodeClientJson($_GET['left']);
		$right = xw::decodeClientJson($_GET['right']);
		xw::logChat($left, $right);
	break;
	
	case 'debug_database':
		debug::db();
	break;
	
	case 'debug_logger':
		debug::logger();
	break;
	
	case 'debug_json':
		debug::json();
	break;
	
	case 'debug_session':
		debug::session();
	break;
	
	case 'debug_login':
		debug::testRegistered($_GET['email'], $_GET['authcode']);
	break;
	
	case 'drop':
		//Drops the current session
		xw::dropSession();
	break;
	
	case 'status':
		//Gives service status
		$statusArray = xw::getServiceStatusArray();
		
		xw::sendJson($statusArray);
	break;
	
	default:
		xw::sendResult(false, 'invalid_action');
		
	break;
}

?>